package com.walle.concurrenttest.pattern.activeobject;

/**
 * @author zhangjiapeng
 * @Package com.walle.concurrenttest.pattern.activeobject
 * @Description: ${todo}
 * @date 2019/2/27 15:39
 */
public class MakeClientThread extends Thread {

    private final ActiveObject activeObject;

    private final char fillChar;

    public MakeClientThread(String name, ActiveObject activeObject, char fillChar) {
        super(name);
        this.activeObject = activeObject;
        this.fillChar = fillChar;
    }

    @Override
    public void run() {
        try {
            for (int i = 0; true ; i++) {
                Result<String> result = activeObject.makeString(i,fillChar);
                Thread.sleep(300);
                String value = result.getResultValue();
                System.out.println(getName() + ": value = " + value);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
